package com.xiaoxin.experience.service.tree.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xiaoxin.experience.api.tree.model.DirectoryInfo;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * @author xiaoxin
 */
@Setter
@Getter
@TableName("tbl_directory_info")
public class DirectoryEntity implements Serializable
{
    private static final long serialVersionUID = 2777378761068830141L;

    /**
     * 目录id
     */
    @TableId(value = "directory_id", type = IdType.AUTO)
    private Integer directoryId;

    /**
     * 目录名称
     */
    @TableField("directory_name")
    private String directoryName;

    /**
     * 父目录id
     */
    @TableField("parent_id")
    private Integer parentId;

    public DirectoryEntity()
    {
    }

    public DirectoryEntity(DirectoryInfo directoryInfo)
    {
        this.directoryId = directoryInfo.getId();
        this.directoryName = directoryInfo.getName();
        this.parentId = directoryInfo.getParentId();
    }

    public DirectoryInfo toInfo()
    {
        DirectoryInfo directoryInfo = new DirectoryInfo();
        directoryInfo.setId(directoryId);
        directoryInfo.setName(directoryName);
        directoryInfo.setParentId(parentId);
        return directoryInfo;
    }
}
